//
//  NewWindowController2.m
//  MacChallengeOC
//
//  Created by xf-ling on 2017/7/21.
//  Copyright © 2017年 LXF. All rights reserved.
//

#import "NewWindowController2.h"

#import "MainWindowController.h"
#import "NewWindowController.h"

@interface NewWindowController2 ()

@property (nonatomic, strong) NewWindowController *nextWindowController;

@end

@implementation NewWindowController2

- (void)windowDidLoad
{
    [super windowDidLoad];
    
    self.window.backgroundColor = [NSColor greenColor];
    
}

- (void)dealloc
{
    NSLog(@"NewWindowController2 dealloc");
}

- (IBAction)lastWinVCBtnFunc:(id)sender
{
    if ([_lastWindowController isKindOfClass:[MainWindowController class]])
    {
        MainWindowController *mainWC = (MainWindowController *)_lastWindowController;
        
        [self.window close];
        mainWC.nextWindowController = nil;
        
        [mainWC.window orderFront:nil];
        
    }
}

- (IBAction)nextWinVCBtnFunc:(id)sender
{
    _nextWindowController = [[NewWindowController alloc] initWithWindowNibName:NSStringFromClass([NewWindowController class])];
    
    //显示需要跳转的窗口
    [_nextWindowController.window orderFront:nil];
    
    //关闭当前窗口
    [self.window orderOut:nil];
}


@end
